﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using MoneyLover.WCFMoneyLover;
namespace MoneyLover.Pages
{
    public partial class Login : PhoneApplicationPage
    {
        public Login()
        {
            InitializeComponent();
        }
        MoneyLoverServiceClient _db = new MoneyLoverServiceClient();
        private void btndangnhap_Click(object sender, RoutedEventArgs e)
        {
           // NavigationService.Navigate(new Uri("/Pages/Login.xaml", UriKind.Relative));
            var user = txtuser.Text.Trim();
            var pass = txtpass.Password.Trim();
            _db.CheckloginCompleted += _db_CheckloginCompleted;
            _db.CheckloginAsync(user, pass);
            // het loi roi gio chi page state
            
        }

        void _db_CheckloginCompleted(object sender, CheckloginCompletedEventArgs e)
        {
            if (e.Result != null)
            {
                Contanst._tkdangnhap = e.Result;
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }
            else
                MessageBox.Show("Đăng nhập không thành công");
        }

        private void btndangky_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Pages/Dangky.xaml", UriKind.RelativeOrAbsolute));
        }
    }
}